package com.laxcen.smoke.dao;

import com.laxcen.smoke.entity.SysLog;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MyLogMapper {

    //添加到日志数据表Web类型
    @Insert("insert into getforsdkmessage(id,username,operation,opurl,loginip,deviceno,type,createtime) value(#{id},#{username},#{operation},#{opurl},#{loginip},#{deviceno},#{type},#{createtime})")
    int insert(SysLog adminLog);

    //根据广告id查询智能柜编号
    @Select("select sm.no from smart sm right join real_smart_advertisement rsa on sm.id = rsa.Smartid where rsa.Adverid = #{advid}")
    String getSmartNoByAd(String advid);

    //获取devicename轮询
    @Select("select distinct sm.no smartno from smart sm right join real_smart_smartboard rss on sm.id = rss.SmartId  ")
    List<String> getSmartNo();

    //根据告警id查询智能柜编号
    @Select("select smartno from abnormalrecord where id = #{abnorid}")
    String getSmartByAbnor(String abnorid);

    //根据智能柜id查询智能柜编号
    @Select("select no from smart where id = #{smartid} ")
    String getSmartBySmartid(String smartid);

    //根据实体柜id查询智能柜编号
    @Select("select distinct sm.no from smart sm right join real_smart_smartboard rss on sm.id = rss.SmartId left join smartboard sb on rss.BoardId = sb.id where rss.BoardId = #{boardid} ")
    String getSmartByBoardid(String boardid);

    //根据格子id查询智能柜编号
    @Select("select distinct sm.no from smart sm right join real_smart_smartboard rss on sm.id = rss.SmartId left join smartboard sb on rss.BoardId = sb.id right join real_board_box rbb on sb.id = rbb.BoardId left join smartbox sbx on rbb.BoxId = sbx.id where rbb.BoxId = #{boxid}")
    String getSmartByBoxid(String boxid);

    //根据格子唯一编号查询格子id
    @Select("select boxid from real_board_box where no = #{boxonlyno}")
    String getboxidByboxonlyno(String boxonlyno);

    //根据用户账号查询用户名
    @Select("select f_username from sys_user where f_account = #{account}")
    String  getUsernameByAccount(String account);

}
